<?php
use Workerman\Worker;
use Workerman\Connection\TcpConnection;
require_once __DIR__ . '/vendor/autoload.php';

// 创建一个 Worker 监听 9501 端口，使用 websocket 协议
$worker = new Worker('tcp://0.0.0.0:9501');

$worker->count = 4;

$worker->onMessage = function(TcpConnection $connection, $data) {
    $connection->send('hello world');
};

$socketName = $worker->getSocketName();
echo "Worker started: https://$socketName\n";

Worker::runAll();

